<template>
  <div>
      <city-header></city-header>
      <city-search :cities='cities'></city-search>
      <city-list :hotcities='hotcities' :cities='cities' :letters='letters'></city-list>
      <city-alphabet :cities='cities' @change="handleChangeClick"></city-alphabet>
  </div>
</template>

<script>
import CityHeader from './components/header'
import CitySearch from './components/search'
import CityList from './components/list'
import CityAlphabet from './components/alphabet'
import axios from 'axios'
export default {
  name: 'City',
  components:{
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data(){
    return{
      hotcities:[],
      cities:{},
      letters:''
    }
  },
  methods:{
    CityGetInfo(){
      axios.get('./mock/city.json').then(this.handleGetInfo)
    },
    handleGetInfo(res){
      res=res.data;
      if(res.ret&&res.data){
        const data=res.data;
        this.hotcities=data.hotCities;
        this.cities=data.cities
      }
    },
    handleChangeClick(letters){
      this.letters=letters
    }
  },
  created(){
    this.CityGetInfo()
  }
 
}
</script>

<style scoped>

</style>
